package com.jyw.business.comp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jyw.common.core.domain.CommonResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jyw.common.annotation.Log;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.AjaxResult;
import com.jyw.common.enums.BusinessType;
import com.jyw.business.comp.domain.CompScheduleTeam;
import com.jyw.business.comp.service.ICompScheduleTeamService;
import com.jyw.common.utils.poi.ExcelUtil;
import com.jyw.common.core.page.TableDataInfo;

/**
 * 综合-班组配置Controller
 * 
 * @author ruoyi
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/comp/team")
public class CompScheduleTeamController extends BaseController
{
    @Autowired
    private ICompScheduleTeamService compScheduleTeamService;

    /**
     * 查询综合-班组配置列表
     */
    @PreAuthorize("@ss.hasPermi('comp:team:list')")
    @GetMapping("/list")
    public TableDataInfo<CompScheduleTeam> list(CompScheduleTeam compScheduleTeam)
    {
        startPage();
        List<CompScheduleTeam> list = compScheduleTeamService.selectCompScheduleTeamList(compScheduleTeam);
        return getDataTable(list);
    }

    /**
     * 导出综合-班组配置列表
     */
    @PreAuthorize("@ss.hasPermi('comp:team:export')")
    @Log(title = "综合-班组配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompScheduleTeam compScheduleTeam)
    {
        List<CompScheduleTeam> list = compScheduleTeamService.selectCompScheduleTeamList(compScheduleTeam);
        ExcelUtil<CompScheduleTeam> util = new ExcelUtil<CompScheduleTeam>(CompScheduleTeam.class);
        util.exportExcel(response, list, "综合-班组配置数据");
    }

    /**
     * 获取综合-班组配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('comp:team:query')")
    @GetMapping(value = "/{id}")
    public CommonResult<CompScheduleTeam> getInfo(@PathVariable("id") Long id)
    {
        return CommonResult.success(compScheduleTeamService.selectCompScheduleTeamById(id));
    }

    /**
     * 新增综合-班组配置
     */
    @PreAuthorize("@ss.hasPermi('comp:team:add')")
    @Log(title = "综合-班组配置", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody CompScheduleTeam compScheduleTeam)
    {
        return CommonResult.success(compScheduleTeamService.insertCompScheduleTeam(compScheduleTeam));
    }

    /**
     * 修改综合-班组配置
     */
    @PreAuthorize("@ss.hasPermi('comp:team:edit')")
    @Log(title = "综合-班组配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody CompScheduleTeam compScheduleTeam)
    {
        return CommonResult.success(compScheduleTeamService.updateCompScheduleTeam(compScheduleTeam));
    }

    /**
     * 删除综合-班组配置
     */
    @PreAuthorize("@ss.hasPermi('comp:team:remove')")
    @Log(title = "综合-班组配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return CommonResult.success(compScheduleTeamService.deleteCompScheduleTeamByIds(ids));
    }
}
